/**
 * 首頁腳本
 */

// 首頁輪播
let indexSlide = new Swiper('#j-slide', {
    autoplay: true,
    loop: true,
    pagination: {
        el: '.slide-pos',
        bulletActiveClass: 'active',
        clickable: true,
    },
    navigation: {
        nextEl: '.next',
        prevEl: '.prev',
    },
    wrapperClass: 'slide-list',
    slideClass: 'slide-item',
    slideActiveClass: 'slide-active'
});

let gameRecSlide = new Swiper('#j-game-rec-slide', {
    slidesPerView: 'auto',
	centeredSlides: true,
	loop: true,
    pagination: {
        el: '.game-rec-pos',
        bulletActiveClass: 'active',
        clickable: true,
    },
    navigation: {
        nextEl: '.game-rec-next',
        prevEl: '.game-rec-prev',
    },
    wrapperClass: 'j-swiper-wrapper',
    slideClass: 'j-swiper-slide',
    slideActiveClass: 'active'
});

let gameBookingSlide = new Swiper('#j-game-booking-slide', {
    slidesPerView: 'auto',
	centeredSlides: true,
	loop: true,
    pagination: {
        el: '.game-booking-pos',
        bulletActiveClass: 'active',
        clickable: true,
    },
    navigation: {
        nextEl: '.game-booking-next',
        prevEl: '.game-booking-prev',
    },
    wrapperClass: 'j-swiper-wrapper',
    slideClass: 'j-swiper-slide',
    slideActiveClass: 'active'
});

window.addEventListener('resize', () => {
    window.requestAnimationFrame(() => {
        indexSlide.update();
        gameRecSlide.update();
        gameBookingSlide.update();
    });
}, false);
